package com.tiorb.imageeffect;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";
    ImageView imageView;
    TextView textView;
    List<float[]> filters = new ArrayList<>();
    String[] names = new String[]{"原图", "黑白", "怀旧", "哥特", "淡雅", "蓝调", "光晕", "梦幻", "酒红", "胶片", "湖光掠影", "褐片", "复古", "泛黄", "传统", "胶片2", "锐色", "清宁", "浪漫", "夜色"};
    int index = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        imageView = findViewById(R.id.image);
        textView = findViewById(R.id.name);
        textView.setText(names[index]);
        initData();
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                index++;
                if (index >= filters.size()) {
                    index = 0;
                }
                Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.bg9);
                imageView.setImageBitmap(BeautyUtil.beautyImage(bitmap, filters.get(index)));
                textView.setText(names[index]);
            }
        });
    }

    private void initData() {
        filters.add(BeautyUtil.colormatrix_yuantu);
        filters.add(BeautyUtil.colormatrix_heibai);
        filters.add(BeautyUtil.colormatrix_gete);
        filters.add(BeautyUtil.colormatrix_danya);
        filters.add(BeautyUtil.colormatrix_landiao);
        filters.add(BeautyUtil.colormatrix_guangyun);
        filters.add(BeautyUtil.colormatrix_menghuan);
        filters.add(BeautyUtil.colormatrix_jiuhong);
        filters.add(BeautyUtil.colormatrix_fanse);
        filters.add(BeautyUtil.colormatrix_huguang);
        filters.add(BeautyUtil.colormatrix_hepian);
        filters.add(BeautyUtil.colormatrix_fugu);
        filters.add(BeautyUtil.colormatrix_huan_huang);
        filters.add(BeautyUtil.colormatrix_chuan_tong);
        filters.add(BeautyUtil.colormatrix_jiao_pian);
        filters.add(BeautyUtil.colormatrix_ruise);
        filters.add(BeautyUtil.colormatrix_qingning);
        filters.add(BeautyUtil.colormatrix_langman);
        filters.add(BeautyUtil.colormatrix_yese);
    }
}